package com.typy.www.tpay.ui.acitivity;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.typy.www.tpay.R;
import com.typy.www.tpay.base.BaseBackActivity;
import com.typy.www.tpay.bean.bean.BaseReturn;
import com.typy.www.tpay.bean.vm.UserInfoVm;
import com.typy.www.tpay.constance.Constance;
import com.typy.www.tpay.constance.Sharep;
import com.typy.www.tpay.ui.view.CircleImageView;
import com.typy.www.tpay.util.ClassHoldUtil;
import com.typy.www.tpay.util.GsonUtils;
import com.typy.www.tpay.util.ParamsUtil;
import com.typy.www.tpay.util.PreferencesUtil;
import com.typy.www.tpay.util.UiHelper;
import com.typy.www.tpay.util.UpdataUiUtil;
import com.typy.www.tpay.util.listviewanimations.IntentUtil;
import com.typy.www.tpay.volley.HTTPUtils;
import com.typy.www.tpay.volley.VolleyListener;
import com.zhy.android.percent.support.PercentLinearLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by 13799 on 2018/6/14.
 */

public class DetailInfomationActivity extends BaseBackActivity {

    @BindView(R.id.img_touxian)
    CircleImageView imgTouxian;
    @BindView(R.id.tv_nickname)
    TextView tvNickname;
    @BindView(R.id.tv_uid)
    TextView tvUid;
    @BindView(R.id.tv_phone)
    TextView tvPhone;
    @BindView(R.id.ll_touxian)
    PercentLinearLayout llTouxian;
    UserInfoVm userInfoVm;
    @BindView(R.id.tv_jihuo)
    TextView tvJihuo;
    @BindView(R.id.tv_zhuanzhang)
    TextView tvZhuanzhang;
    @BindView(R.id.tv_shanchu)
    TextView tvShanchu;

    public static void show(Context context) {
        IntentUtil.intent2Activity(context, DetailInfomationActivity.class);
    }

    @Override
    protected void initView() {
        super.initView();
        ButterKnife.bind(this);
        setTitle("详细资料");
        getData();
    }

    @Override
    protected int getContentResId() {
        return R.layout.activity_detailinfo;
    }

    //获取个人信息
    private void getData() {
        ParamsUtil params = new ParamsUtil();
        HTTPUtils.post(this, Constance.getMyselfinfoURL(), params.getParams(), new VolleyListener() {
            @Override
            public void onResponse(BaseReturn ret) {
                userInfoVm = GsonUtils.parseJSON(ret.getData().toString(), UserInfoVm.class);
                updataUserInfo();
            }

            @Override
            public void onResponseErr(int code, String msg) {
                UiHelper.showToast(getActivity(), msg);
            }
        });
    }

    private void updataUserInfo() {
        if (userInfoVm != null)
            UpdataUiUtil.getDefaul().setText(userInfoVm.getFdNickName(), tvNickname)
                    .setText("UID:" + userInfoVm.getFdId(), tvUid)
                    .setText("手机号:" + userInfoVm.getFdCode(), tvPhone);

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.tv_jihuo, R.id.tv_zhuanzhang, R.id.tv_shanchu})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_jihuo:
                ActivicationActivity.show(getActivity(), ClassHoldUtil.Activication);
                break;
            case R.id.tv_zhuanzhang:
                break;
            case R.id.tv_shanchu:
                break;
        }
    }
}
